import 'package:auto_route/auto_route.dart';
import 'package:distribution_mall_flutter/assets.dart';
import 'package:distribution_mall_flutter/generated/l10n.dart';
import 'package:distribution_mall_flutter/provider/delete_account/delete_account.dart';
import 'package:distribution_mall_flutter/utils/common_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

@RoutePage()
class DeleteAccountLoadingPage extends ConsumerStatefulWidget {
  const DeleteAccountLoadingPage({super.key});

  @override
  ConsumerState createState() => _DeleteAccountLoadingPageState();
}

class _DeleteAccountLoadingPageState
    extends ConsumerState<DeleteAccountLoadingPage> {
  @override
  Widget build(BuildContext context) {
    ref.watch(deleteAccountCheckProvider);
    ref.listen(deleteAccountCheckProvider,(_,__){
      ref.read(deleteAccountCheckProvider.notifier).checkAccount(context);
    });
    return Scaffold(
      appBar: AppBar(
        title: const Text('Security check'),
        leading: CommonBtnWidget.arrowBack(),
      ),
      bottomNavigationBar: Container(
          width: double.infinity,
          height: 40,
          margin:
              const EdgeInsets.only(left: 24, right: 24, bottom: 33, top: 16),
          child: ElevatedButton(
            onPressed: () {
              ref.read(deleteAccountCheckProvider.notifier).checkAccount(context);
            },
            child: Text('Proceed'),
          )),
      body: Column(
        children: [
          const Divider(
            height: 1,
          ),
          Container(
            decoration: BoxDecoration(
              color: const Color(0xFF3F3F3F),
              borderRadius: BorderRadius.circular(14),
            ),
            margin: const EdgeInsets.only(top: 189, bottom: 24),
            padding: const EdgeInsets.symmetric(horizontal: 33, vertical: 31),
            child: Image.asset(
              Assets.assets_icons_delete_account_delete_loading_png,
              width: 34,
            ),
          ),
          const Text(
            'VERIFYING YOUR ACCOUNT......',
            style: TextStyle(fontSize: 14, color: Colors.black),
          ),
        ],
      ),
    );
  }
}

class NoticeItem extends StatelessWidget {
  final String text;

  const NoticeItem({
    super.key,
    required this.text,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(bottom: 20),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                margin: const EdgeInsets.only(right: 16, top: 5),
                width: 10,
                height: 10,
                decoration: const BoxDecoration(
                    color: Color(0xFFF79F31), shape: BoxShape.circle),
              ),
              Expanded(
                  child: Text(
                text,
                style: const TextStyle(fontSize: 14, color: Color(0xFF303030)),
              ))
            ],
          )
        ],
      ),
    );
  }
}
